import React, { Component, useState, useEffect } from 'react'

export default function Time() {

    let [year, setYear] = useState<any>()
    let [mon, setMon] = useState<any>()
    let [day, setDay] = useState<any>()
    let [hour, setHour] = useState<any>()
    let [min, setMin] = useState<any>()
    let [sec, setSec] = useState<any>()
    let [week, setWeek] = useState<any>()
    let lists = ["日", "一", "二", "三", "四", "五", "六"]

    let date = new Date()

    setTimeout(() => {
        setYear(date.getFullYear())
        setMon(date.getMonth())
        setDay(date.getDate())
        setHour(date.getHours())
        setMin(date.getMinutes())
        setSec(date.getSeconds())
        setWeek(date.getDay())
    }, 1000);


    return (
        <div className='times'>
            <span>{year}</span>年<span>{mon}</span>月<span>{day}</span>日  <span>{hour}</span>:<span>{min}</span>:<span>{sec}</span> 星期<span>{lists[week]}</span>
        </div>
    )
}

